<?php 
class Erpuser extends User
{
	//通过昵称找id
	static function lookup_by_nick($nick)
	{
		$user_nick = ORM::factory('user')->where('nick', '=', $nick)->find();
		
		return $user_nick->loaded()?$user_nick->id:NULL;
	}
	
	//通过id找昵称
	static function nick_by_id($id)
	{
		$nick = user::lookup($id);
		return isset($nick->nick)?$nick->nick:NULL;
	}
    //通过id找昵称
    static function name_by_id($id)
    {
        $nick = user::lookup($id);
        return isset($nick->name)?$nick->name:NULL;
    }
    //通过id找邮箱
    static function mail_by_id($id)
    {
        $nick = user::lookup($id);
        return isset($nick->mail)?$nick->mail:NULL;
    }
}